package com.work.vo.bd;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.node.INode;

import java.util.ArrayList;
import java.util.List;

/**
 * 队组树形
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/20 9:05
 */
@Data
public class BdTeamTreeVO implements INode<BdTeamTreeVO> {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "主键ID")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "ID")
    private Long transportCorpId;

    @ApiModelProperty(value = "transportCorpId value")
    private String value;

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "名称 text")
    private String text;

    @ApiModelProperty(value = "名称 label")
    private String label;

    @ApiModelProperty(value = "父级ID")
    private Long parentId;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "是否结尾")
    private Boolean isLeaf;

    public Boolean getIsLeaf() {
        return getChildren().isEmpty();
    }

    /**
     * 子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @ApiModelProperty(value = "子孙节点")
    private List<BdTeamTreeVO> children;

    @Override
    public List<BdTeamTreeVO> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return this.children;
    }

}
